include ../../../Makefile.env

TARGET = publisher-complexdata
TARGETNAME = $(TARGET)

ifeq ($(MAKECMDGOALS),make)
$(shell cd src; $(STAFF_CODEGEN) -u -tmqdata -e ComplexData.h >&2)
endif

CXXFLAGS += -c -Wno-deprecated -fexceptions
LDFLAGS += -fexceptions -L$(DEPLOYDIR)lib -L$(STAFF_HOME)/lib -L$(AXIS2C_HOME)/lib
LDFLAGS += -lrise -lstaffcommon  -laxis2_axiom -lstaffmqclient

VPATH = $(subst $(empty) $(empty),:,$(SRCDIR))

SOURCES = $(wildcard $(SRCDIR)*.cpp)
OBJECTS = $(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(SOURCES)))

# == make ===========================================
make: check "$(OBJDIR)" "$(OUTDIR)" $(OUTDIR)$(TARGETNAME) deploy

# link
$(OUTDIR)$(TARGETNAME): $(OBJECTS)
	$(CXX) $(LDFLAGS) $(OBJECTS) -o $(OUTDIR)$(TARGETNAME)

# compile
$(OBJDIR)%.o: %.cpp
	$(CXX) $(CXXFLAGS) $< -o $@

# == deploy ========================================
deploy: "$(DEPLOYDIR)" "$(DEPLOYDIR)$(BINDIR)" $(OUTDIR)$(TARGETNAME)
	cp -f $(OUTDIR)$(TARGETNAME) $(DEPLOYDIR)$(BINDIR)$(TARGETNAME)

# == distrib =========================================
distrib:;

# == install ========================================
install: check "$(INSTALLDIR)samples/mq/$(BINDIR)"
	cp -f $(OUTDIR)$(TARGETNAME) $(INSTALLDIR)samples/mq/$(BINDIR)$(TARGETNAME)

# == clean ==========================================
clean:
	rm -Rf $(OBJDIR) $(OUTDIR)
	rm -f $(SRCDIR)*Proxy.h $(SRCDIR)*Proxy.cpp

# == uninstall ======================================
uninstall: check
	rm -f $(INSTALLDIR)$(LIBDIR)$(TARGETNAME)

# == mkdir ==========================================
"%/":
	@[ -z "$@" -o -d "$@" ] || mkdir -p $@ && chmod g+w $@
